﻿@model EC_ASS.Models.Order

<script>
    $(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); });
</script>
<div id="editOrderDiv">
    <div class="alert alert-success" id="successMSG">Cập nhật thành công đơn hàng!</div>
    <form action="@Url.Action("UpdateOrder", "Admin")" class="form-horizontal" style="margin-top: 20px;" method="post" data-spy="scroll" id="editOrderForm">
        <div class="control-group">
            <label class="control-label" for="Buyer">Người mua</label>
            <div class="controls">
                <input value="@Model.Buyer" type="text" id="Buyer" name="Buyer" required/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="BuyerPhone">Số ĐT</label>
            <div class="controls">
                <input name="BuyerPhone" type="text" placeholder="VD: 01889135342" maxlength="11" value="@Model.BuyerPhone"
                                    pattern="^[0-9]+$" data-validation-pattern-message="Sai định dạng"
                                    required data-validation-required-message="Vui lòng nhập thông tin"/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="Receiver">Người nhận</label>
            <div class="controls">
                <input value="@Model.Receiver" type="text" id="Receiver" name="Receiver" required />
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="Receiver">Số ĐT</label>
            <div class="controls">
                <input name="ShipPhone" type="text" placeholder="VD: 01889135342" maxlength="11" value="@Model.ShipPhone"
                                    pattern="^[0-9]+$" data-validation-pattern-message="Sai định dạng"
                                    required data-validation-required-message="Vui lòng nhập thông tin"/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="ShipAddress">Địa chỉ ship</label>
            <div class="controls">
                <input value="@Model.ShipAddress" type="text" id="ShipAddress" name="ShipAddress" required/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="ShipFee">Phí ship</label>
            <div class="controls">
                <input value="@Model.ShipFee" type="text" id="ShipFee" name="ShipFee" required/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="Total">Tổng giá đơn hàng</label>
            <div class="controls">
                <input value="@Model.Total" type="text" id="Total" name="Total" required/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="Total">Trạng thái</label>
            <div class="controls">

                <select name="CheckedOut" required>
                    @if (Model.CheckedOut)
                    {
                        <option value="True" selected="selected">Đã duyệt</option>
                        <option value="Flase">Chưa duyệt</option>
                    }
                    else
                    {
                        <option value="True">Đã duyệt</option>
                        <option value="Flase" selected="selected">Chưa duyệt</option>
                    }
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="Total">Ghi chú</label>
            <div class="controls">
                <textarea name="Note" rows="4">@Model.Note</textarea>
            </div>
        </div>
        <input type="hidden" name="ID" value="@Model.ID"/>
        <div class="control-group">
            <div class="controls">
                <button type="submit" class="btn">Cập nhập</button>
            </div>
        </div>
    </form>
</div>
<script>
    $(function () {
        $('#successMSG').hide();
        $('#editOrderForm').submit(function () {
            $.ajax({
                url: $(this).attr("action"),
                type: "POST",
                data: $(this).serialize(),
                success: function () {
                    $('#editOrderForm').hide();
                    $('#successMSG').show();
                    setTimeout(function () {
                        $('#editModal').modal('hide');
                    }, 2000);
                    setTimeout(function () {
                        $('#listOrderTable').load('@Url.Action("_LoadOrder", "Admin")').hide().fadeIn('slow');
                    }, 2000);
                }
            });
            return false;
        });
    });
</script>
